<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fn(a){
            var sum = 0;
            for(var i=1; i<a; i++){
                if(a%i == 0){
                    sum = sum +i;
                }
            }
            return sum == a;
        }
        function fun(n,m){
            for(var i=n;i<m;i++){
                fn(i) && document.write(i+' ');
            }
        }
        fun(1,1000);
    </script>
</body>
</html>